<template>
  <div class="card">
    <el-card class="box-card" :style="{height:WindowHeight - cardHeight + 'px'}">
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="未使用" name="first">
          <el-table :max-height="WindowHeight - tabHeight" :data="tableData1" style="width:100" border stripe>
            <el-table-column label="序号" type="index" fixed align="center" width="60" />
            <el-table-column prop="genre" label="发票类型" width="120" header-align="center" />
            <el-table-column prop="contant" label="发票内容" show-overflow-tooltip width="120" header-align="center" />
            <el-table-column prop="moblie" label="发票号" width="120" header-align="center" />
            <el-table-column prop="date" label="发票日期" width="120" align="center" />
            <el-table-column prop="sum" label="发票金额" width="120" header-align="center">
              <template slot-scope="scope">
                <div class="right">
                  <span v-text="scope.row.sum" />
                  <span>元</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column prop="rate" label="税率" width="80" header-align="center">
              <template slot-scope="scope">
                <div :class="setAlign(scope.row.rate)">
                  <span v-text="scope.row.rate" />
                  <span>%</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column prop="amount" label="税额" width="100" header-align="center">
              <template slot-scope="scope">
                <div class="right">
                  <span v-text="scope.row.amount" />
                  <span>元</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column prop="uploaduser" label="上传人" width="100" align="center" />
            <el-table-column prop="uploadData" label="上传日期" width="120" align="center" />
            <el-table-column label="操作" min-width="220" fixed="right" align="center">
              <el-button size="small" type="info" @click="lookimg">查看</el-button>
              <el-button size="small" type="success">下载</el-button>
              <el-button size="small" type="danger">删除</el-button>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="已使用" name="second">
          <el-table :max-height="WindowHeight - tabHeight" :data="tableData2" style="width:100" border stripe>
            <el-table-column label="序号" type="index" fixed align="center" width="60" />
            <el-table-column prop="genre" label="发票类型" width="120" header-align="center" />
            <el-table-column prop="contant" label="发票内容" show-overflow-tooltip width="120" header-align="center" />
            <el-table-column prop="moblie" label="发票号" width="120" header-align="center" />
            <el-table-column prop="date" label="发票日期" width="120" align="center" />
            <el-table-column prop="sum" label="发票金额" width="120" header-align="center">
              <template slot-scope="scope">
                <div class="right">
                  <span v-text="scope.row.sum" />
                  <span>元</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column prop="rate" label="税率" width="80" header-align="center">
              <template slot-scope="scope">
                <div :class="setAlign(scope.row.rate)">
                  <span v-text="scope.row.rate" />
                  <span>%</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column prop="amount" label="税额" width="100" header-align="center">
              <template slot-scope="scope">
                <div class="right">
                  <span v-text="scope.row.amount" />
                  <span>元</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column prop="uploaduser" label="上传人" width="100" align="center" />
            <el-table-column prop="uploadData" label="上传日期" width="120" align="center" />
            <el-table-column prop="dataService" label="使用日期" width="120" align="center" />
            <el-table-column label="操作" align="center" fixed="right" min-width="160">
              <el-button size="small" type="info" @click="lookimg">查看</el-button>
              <el-button size="small" type="success">下载</el-button>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="验证未通过" name="third">
          <el-table :max-height="WindowHeight - tabHeight" :data="tableData3" style="width:100" border stripe>
            <el-table-column label="序号" type="index" fixed align="center" width="60" />
            <el-table-column prop="genre" label="发票类型" width="120" header-align="center" />
            <el-table-column prop="contant" label="发票内容" show-overflow-tooltip width="120" header-align="center" />
            <el-table-column prop="moblie" label="发票号" width="120" header-align="center" />
            <el-table-column prop="date" label="发票日期" width="120" align="center" />
            <el-table-column prop="sum" label="发票金额" width="120" header-align="center">
              <template slot-scope="scope">
                <div class="right">
                  <span v-text="scope.row.sum" />
                  <span>元</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column prop="rate" label="税率" width="80" header-align="center">
              <template slot-scope="scope">
                <div :class="setAlign(scope.row.rate)">
                  <span v-text="scope.row.rate" />
                  <span>%</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column prop="amount" label="税额" width="100" header-align="center">
              <template slot-scope="scope">
                <div class="right">
                  <span v-text="scope.row.amount" />
                  <span>元</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column prop="uploaduser" label="上传人" width="100" align="center" />
            <el-table-column prop="uploadData" label="上传日期" width="120" align="center" />
            <el-table-column prop="notcause" label="未通过原因" show-overflow-tooltip width="150" align="left" />
            <el-table-column label="操作" align="center" fixed="right" width="220">
              <el-button size="small" type="info" @click="lookimg">查看</el-button>
              <el-button size="small" type="success">下载</el-button>
              <el-button size="small" type="danger">删除</el-button>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="全部" name="four">
          <el-table :max-height="WindowHeight - tabHeight" :data="tableData" style="width:100" border stripe>
            <el-table-column label="序号" type="index" fixed align="center" width="60" />
            <el-table-column prop="genre" label="发票类型" width="120" header-align="center" />
            <el-table-column prop="contant" label="发票内容" show-overflow-tooltip width="120" header-align="center" />
            <el-table-column prop="moblie" label="发票号" width="120" header-align="center" />
            <el-table-column prop="date" label="发票日期" width="120" align="center" />
            <el-table-column prop="sum" label="发票金额" width="120" header-align="center">
              <template slot-scope="scope">
                <div class="right">
                  <span v-text="scope.row.sum" />
                  <span>元</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column prop="rate" label="税率" width="80" header-align="center">
              <template slot-scope="scope">
                <div :class="setAlign(scope.row.rate)">
                  <span v-text="scope.row.rate" />
                  <span>%</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column prop="amount" label="税额" width="100" header-align="center">
              <template slot-scope="scope">
                <div class="right">
                  <span v-text="scope.row.amount" />
                  <span>元</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column prop="uploaduser" label="上传人" width="100" align="center" />
            <el-table-column prop="uploadData" label="上传日期" width="120" align="center" />
            <el-table-column prop="notcause" label="未通过原因" show-overflow-tooltip width="150" header-align="center" />
            <el-table-column label="操作" align="center" fixed="right" width="220">
              <el-button size="small" type="info" @click="lookimg">查看</el-button>
              <el-button size="small" type="success">下载</el-button>
              <el-button size="small" type="danger">删除</el-button>
            </el-table-column>
          </el-table>
        </el-tab-pane>
      </el-tabs>
      <el-button-group class="BtnAll">
        <el-button size="small" type="primary" @click="newfapiao">上传发票</el-button>
      </el-button-group>
      <div class="bottom"><page /></div>
    </el-card>
    <!-- 图片预览 -->
    <el-dialog :visible.sync="imga" :close-on-click-modal="false" :class="[isActive?'el-dialog__body,.el-dialog__header':'']">
      <el-carousel height="400px">
        <el-carousel-item v-for="item in srcList" :key="item.id">
          <el-image style="width: 100; height: 100" :src="item.imgUrl" />
        </el-carousel-item>
      </el-carousel>
      <!-- <p class="btn-img" @click="imga=false">
        <span>X</span>
      </p> -->
    </el-dialog>
    <component :is="configName" />
  </div>
</template>

<script>
import page from '@/views/rfcwgl/components/PageS/index.vue'
import Vue from 'vue'
export default {
  components: { page },
  data() {
    return {
      configName: '',
      addPath: {
        configName: 'addfapaio',
        configFilePath: 'rfcwgl/faPiaoGL/append/faPiaoGLAppend/index.vue'
      },
      WindowHeight: document.body.clientHeight,
      cardHeight: 84,
      tabHeight: 180,
      activeName: 'first',
      dialogImageUrl: '',
      showfp: false,
      imga: false,
      isActive: false,
      // url: imgfapiao,
      srcList: [
        { imgUrl: require('@/assets/img/fa(1).jpg'), id: 1 },
        { imgUrl: require('@/assets/img/fa(2).jpg'), id: 2 },
        { imgUrl: require('@/assets/img/fa(3).jpg'), id: 3 }
      ],
      tableData1: [
        {
          date: '2016-05-04',
          genre: '增值税发票',
          contant: '住宿费',
          moblie: '032370311',
          rate: 2,
          amount: '3.00',
          sum: '100.00',
          dataService: '',
          uploaduser: '张三',
          uploadData: '2016-05-04',
          notcause: ''
        },
        {
          date: '2019-05-04',
          genre: '机票',
          contant: '出差',
          moblie: '032370121',
          rate: 0.8,
          amount: '45.90',
          dataService: '',
          uploaduser: '王五',
          uploadData: '2020-01-04',
          notcause: '',
          sum: '1200.00'
        },
        {
          date: '2020-02-01',
          genre: '增值税发票',
          contant: '餐费',
          moblie: '03237032',
          rate: 3,
          amount: '24.00',
          dataService: '2016-05-04',
          uploaduser: '李四',
          uploadData: '2020-03-01',
          notcause: '',
          sum: '2000.00'
        },
        {
          date: '2016-05-03',
          genre: '其他发票',
          contant: '餐费',
          moblie: '03237003',
          rate: 4,
          amount: '3.00',
          dataService: '2016-05-04',
          uploaduser: '王五',
          uploadData: '2016-05-04',
          notcause: '字体不清楚',
          sum: '100.00'
        },
        {
          date: '2016-05-04',
          genre: '增值税发票',
          contant: '住宿费',
          moblie: '032370311',
          rate: 5,
          amount: '3.00',
          sum: '100.00',
          dataService: '',
          uploaduser: '张三',
          uploadData: '2016-05-04',
          notcause: ''
        },
        {
          date: '2016-05-04',
          genre: '其他发票',
          contant: '会议费',
          moblie: '032370121',
          rate: 1,
          amount: '45.90',
          dataService: '',
          uploaduser: '王五',
          uploadData: '2016-05-04',
          notcause: '',
          sum: '1530.00'
        },
        {
          date: '2016-05-01',
          genre: '增值税发票',
          contant: '交通费',
          moblie: '03237032',
          rate: 2.4,
          amount: '24.00',
          dataService: '2016-05-04',
          uploaduser: '李四',
          uploadData: '2016-05-04',
          notcause: '字体不清楚',
          sum: '800.00'
        },
        {
          date: '2016-05-03',
          genre: '其他发票',
          contant: '餐费',
          moblie: '03237003',
          rate: 1.6,
          amount: '3.00',
          dataService: '2016-05-04',
          uploaduser: '王五',
          uploadData: '2016-05-04',
          notcause: '字体不清楚',
          sum: '100.00'
        },
        {
          date: '2016-05-04',
          genre: '增值税发票',
          contant: '住宿费',
          moblie: '032370311',
          rate: 3,
          amount: '3.00',
          sum: '100.00',
          dataService: '',
          uploaduser: '张三',
          uploadData: '2016-05-04',
          notcause: ''
        },
        {
          date: '2016-05-04',
          genre: '其他发票',
          contant: '会议费',
          moblie: '032370121',
          rate: 3,
          amount: '45.90',
          dataService: '',
          uploaduser: '王五',
          uploadData: '2016-05-04',
          notcause: '',
          sum: '1530.00'
        },
        {
          date: '2016-05-01',
          genre: '增值税发票',
          contant: '交通费',
          moblie: '03237032',
          rate: 3,
          amount: '24.00',
          dataService: '2016-05-04',
          uploaduser: '李四',
          uploadData: '2016-05-04',
          notcause: '字体不清楚',
          sum: '800.00'
        },
        {
          date: '2016-05-03',
          genre: '其他发票',
          contant: '餐费',
          moblie: '03237003',
          rate: 3,
          amount: '3.00',
          dataService: '2016-05-04',
          uploaduser: '王五',
          uploadData: '2016-05-04',
          notcause: '字体不清楚',
          sum: '100.00'
        },
        {
          date: '2016-05-04',
          genre: '增值税发票',
          contant: '住宿费',
          moblie: '032370311',
          rate: 3,
          amount: '3.00',
          sum: '100.00',
          dataService: '',
          uploaduser: '张三',
          uploadData: '2016-05-04',
          notcause: ''
        },
        {
          date: '2016-05-04',
          genre: '其他发票',
          contant: '会议费',
          moblie: '032370121',
          rate: 3,
          amount: '45.90',
          dataService: '',
          uploaduser: '王五',
          uploadData: '2016-05-04',
          notcause: '',
          sum: '1530.00'
        },
        {
          date: '2016-05-01',
          genre: '增值税发票',
          contant: '交通费',
          moblie: '03237032',
          rate: 3,
          amount: '24.00',
          dataService: '2016-05-04',
          uploaduser: '李四',
          uploadData: '2016-05-04',
          notcause: '字体不清楚',
          sum: '800.00'
        },
        {
          date: '2016-05-03',
          genre: '其他发票',
          contant: '餐费',
          moblie: '03237003',
          rate: 3,
          amount: '3.00',
          dataService: '2016-05-04',
          uploaduser: '王五',
          uploadData: '2016-05-04',
          notcause: '字体不清楚',
          sum: '100.00'
        }
      ],
      tableData2: [
        {
          date: '2018-05-14',
          genre: '增值税发票',
          contant: '酒店住宿',
          moblie: '0321370311',
          rate: 3,
          amount: '3.00',
          sum: '5000.00',
          dataService: '2016-05-04',
          uploaduser: '赵四',
          uploadData: '2019-01-01',
          notcause: '字体不清楚'
        },
        {
          date: '2016-05-04',
          genre: '其他发票',
          contant: '会议费',
          moblie: '032370121',
          rate: 3,
          amount: '45.90',
          dataService: '2016-05-04',
          uploaduser: '王五',
          uploadData: '2016-05-04',
          notcause: '字体不清楚字体不清楚字体不清楚字体不清楚字体不清楚字体不清楚字体不清楚字体不清楚字体不清楚',
          sum: '1530.00'
        },
        {
          date: '2016-05-01',
          genre: '增值税发票',
          contant: '交通费',
          moblie: '03237032',
          rate: 3,
          amount: '24.00',
          dataService: '2016-05-04',
          uploaduser: '李四',
          uploadData: '2016-05-04',
          notcause: '字体不清楚',
          sum: '800.00'
        },
        {
          date: '2016-05-03',
          genre: '其他发票',
          contant: '餐费',
          moblie: '03237003',
          rate: 3,
          amount: '3.00',
          dataService: '2016-05-04',
          uploaduser: '王五',
          uploadData: '2016-05-04',
          notcause: '字体不清楚',
          sum: '100.00'
        }
      ],
      tableData3: [
        {
          date: '2018-05-14',
          genre: '增值税发票',
          contant: '酒店住宿',
          moblie: '0321370311',
          rate: 3,
          amount: '3.00',
          sum: '5000.00',
          dataService: '2016-05-04',
          uploaduser: '赵四',
          uploadData: '2019-01-01',
          notcause: '字体不清楚'
        },
        {
          date: '2016-05-04',
          genre: '其他发票',
          contant: '会议费',
          moblie: '032370121',
          rate: 3,
          amount: '45.90',
          dataService: '2016-05-04',
          uploaduser: '王五',
          uploadData: '2016-05-04',
          notcause: '字体不清楚字体不清楚字体不清楚字体不清楚字体不清楚字体不清楚字体不清楚字体不清楚字体不清楚',
          sum: '1530.00'
        },
        {
          date: '2016-05-01',
          genre: '增值税发票',
          contant: '交通费',
          moblie: '03237032',
          rate: 3,
          amount: '24.00',
          dataService: '2016-05-04',
          uploaduser: '李四',
          uploadData: '2016-05-04',
          notcause: '字体不清楚字体不清楚字体不清楚字体不清楚字体不清楚字体不清楚字体不清楚字体不清楚字体不清楚',
          sum: '800.00'
        },
        {
          date: '2016-05-03',
          genre: '其他发票',
          contant: '餐费',
          moblie: '03237003',
          rate: 3,
          amount: '3.00',
          dataService: '2016-05-04',
          uploaduser: '王五',
          uploadData: '2016-05-04',
          notcause: '字体不清楚',
          sum: '100.00'
        }
      ],
      tableData: [
        {
          date: '2018-05-14',
          genre: '增值税发票',
          contant: '酒店住宿',
          moblie: '0321370311',
          rate: 3,
          amount: '3.00',
          sum: '5000.00',
          dataService: '2016-05-04',
          uploaduser: '赵四',
          uploadData: '2019-01-01',
          notcause: '字体不清楚'
        },
        {
          date: '2016-05-04',
          genre: '其他发票',
          contant: '会议费',
          moblie: '032370121',
          rate: 3,
          amount: '45.90',
          dataService: '2016-05-04',
          uploaduser: '王五',
          uploadData: '2016-05-04',
          notcause: '字体不清楚字体不清楚字体不清楚字体不清楚字体不清楚字体不清楚字体不清楚字体不清楚字体不清楚',
          sum: '1530.00'
        },
        {
          date: '2016-05-01',
          genre: '增值税发票',
          contant: '交通费',
          moblie: '03237032',
          rate: 3,
          amount: '24.00',
          dataService: '2016-05-04',
          uploaduser: '李四',
          uploadData: '2016-05-04',
          notcause: '字体不清楚',
          sum: '800.00'
        },
        {
          date: '2016-05-03',
          genre: '其他发票',
          contant: '餐费',
          moblie: '03237003',
          rate: 3,
          amount: '3.00',
          dataService: '2016-05-04',
          uploaduser: '王五',
          uploadData: '2016-05-04',
          notcause: '字体不清楚',
          sum: '100.00'
        }
      ]
    }
  }, 
  computed: {
    windowHeight() {
      return this.$store.state.windowH.height
    },
    tagsView() {
      return this.$store.state.settings.tagsView
    }
  },
  watch: {
    imga: 'lookimger',
    windowHeight: function(old, newd) {
      this.WindowHeight = old
    },
    tagsView: function(old, newd) {
      this.ifTagsView(old)
    }

  },
  created() {
    this.ifTagsView(this.$store.state.settings.tagsView)
  },
  methods: {
    ifTagsView(data) {
      if (data) {
        this.cardHeight = 84
        this.tabHeight = 180
      } else {
        this.cardHeight = 50
        this.tabHeight = 155
      }
    },
    newfapiao() {
      this.openWndow(this.addPath)
    },
    openWndow(e) {
      this.configName = Vue.component(e.configName, resolve => {
        require([`@/views/${e.configFilePath}`], resolve)
      })
    },
    handleClick(tab, event) {
      console.log(tab, event)
    },
    changefp() {
      this.$refs.changfp.openfp()
    },
    // 查看大图
    lookimg() {
      this.imga = true
      this.isActive = true
    },
    lookimger() {
      // this.imga = false
      this.isActive = false
    },
    setAlign(data) {
      const type = typeof data
      // console.log(type)
      if (type === 'text') {
        return 'left'
      } else if (type === 'date') {
        return 'center'
      } else if (type === 'string') {
        return 'left'
      } else if (type === 'boolean') {
        return 'center'
      } else if (type === 'number') {
        // console.log(data)
        return 'right'
      }
    }
  }
}
</script>

<style lang='scss' scoped>
::v-deep .el-tabs__header {
  margin: 0px;
}
</style>
